<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Account_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
	}
	
	function login($param)
	{
		$limit = 1;
		$offset = 0;
		$query = $this->db->get_where('qa_users', $param, $limit, $offset);
		if($query->num_rows() > 0)
		{
			return $query->row_array();
		}
		else 
		{
			log_message('error','account_model->login: '.$this->db->_error_message());
			return null;
		}
	
	}

	function register($param)
	{
		$query = $this->db->insert('qa_users', $param);
		
		if($this->db->insert_id() > 0)
		{
			return $this->db->insert_id();
		}
		else
		{
			log_message('error','account_mode->register() :'.$this->db->_error_message());
			show_error('Unable to register user');
			return 0;
		}
		
		return 0;
	}
}
